<?php

declare(strict_types=1);

namespace App\Model;


/**
 * @property int $id ID
 * @property int $userid 用户ID
 * @property int $coins 金币奖励
 * @property int $integral 积分奖励
 * @property int $days 连续签到天数
 * @property int $date 签到日期
 * @property int $add_time 签到时间
 * @property-read null|User $user 
 */
class Sign extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'sign';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'userid', 'coins', 'integral', 'days', 'date', 'add_time'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'userid' => 'integer', 'coins' => 'integer', 'integral' => 'integer', 'days' => 'integer', 'date' => 'integer', 'add_time' => 'integer'];

    public function user(){
        return $this->hasOne(User::class, 'id', 'userid')->select(['id', 'username', 'nickname', 'avatar', 'role_id']);
    }
}
